import { _decorator, Component, Node } from 'cc';
import { GameTags } from '../constants/GameConstants';

const { ccclass, property } = _decorator;

@ccclass('Food')
export class Food extends Component {
    @property
    public nutritionValue: number = 10;

    @property
    public lifeTime: number = 30;

    private timer: number = 0;

    start() {
        // 设置标签
        this.node.name = GameTags.FOOD;
    }

    update(deltaTime: number) {
        // 食物生命周期
        this.timer += deltaTime;
        if (this.timer >= this.lifeTime) {
            this.node.destroy();
        }
    }
} 